<template>
	<div class="page">
		<c-title :hide="false" text="添加体检报告"></c-title>
		<van-field v-model="name" label="体检名称" placeholder="请输入体检名称" />
		<van-field @click=" pickerShow = true" v-model="time" label="体检时间" placeholder="请输入体检时间" />
		<van-field v-model="content" rows="2" autosize label="体检内容" type="textarea" maxlength="50"
			placeholder="请输入体检内容" show-word-limit />
			<van-popup v-model="pickerShow" :close-on-click-overlay="false" position="bottom">
			  <van-datetime-picker
			    type="date"
			    title="选择年月日"
			    v-model="pickerValue"
			    @cancel="pickerShow = false"
			    @confirm="setDate"
			  />
			</van-popup>
			<div class="submit" @click="submit">提交</div>   
	</div>
</template>

<script>
	import {
		Toast
	} from 'vant';
	export default {
		data() {
			return {
				name: '',
				content: '',
				time: '',
				pickerShow:false,
				pickerValue: new Date(),
			}
		},
		methods:{
			submit(){
				$http
					.post("plugin.hft-hospital.api.jiankang.submit-tijian-data", {
						name: this.name,
						content: this.content,
						time: this.time,
					
					})
					.then(response => {
						console.log(response)
						if (response.result === 1) {
							Toast('添加成功！')
						this.$router.go(-1);
						} else {
							Toast(response.msg);
						}
					})
					.catch(error => {
						console.log(error);
					});
			},
			setDate(ret) {
			
			      this.time=ret.Format("yyyy-MM-dd");
			 
			  this.pickerShow = false;
			},
		}
	}
</script>

<style scoped lang="scss">
	.submit{
		position: fixed;
		bottom: 0;
		width: 100%;
		line-height: 2rem;
		color: #fff;
		background-color: #169BD5;
	}
</style>
